package com.chat.xx;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import tk.mybatis.spring.annotation.MapperScan;

import java.net.InetAddress;
import java.net.UnknownHostException;

@EnableAsync
@EnableScheduling
@EnableCaching
@SpringBootApplication
@MapperScan(basePackages = {"com.chat.xx.mapper"})
@ComponentScan(basePackages = {"com.chat.xx.*"})
@Slf4j
public class ChatServerApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext application = SpringApplication.run(ChatServerApplication.class, args);
        Environment env = application.getEnvironment();
        try {
            log.info("\n----------------------------------------------------------\n\t" +
                            "Application '{}' is running! Access URLs:\n\t" +
                            "Local: \t\thttp://localhost:{}/doc.html\n\t" +
                            "External: \thttp://{}:{}\n\t"+
                            "----------------------------------------------------------",
                    env.getProperty("spring.application.name"),
                    env.getProperty("server.port"),
                    InetAddress.getLocalHost().getHostAddress(),
                    env.getProperty("server.port"));
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }

}
